package com.wytec.xywzxw.utils;

import oshi.SystemInfo;
import oshi.hardware.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HardWareUtils {

   static public Map<String,Object> getHardWareInfo(){
      SystemInfo systemInfo = new SystemInfo();
      //硬件信息
      HardwareAbstractionLayer hardware = systemInfo.getHardware();

      //cpu信息
      CentralProcessor processor = hardware.getProcessor();

      //处理器型号名
      String name = processor.getProcessorIdentifier().getName();
      //物理处理器数
      int physicalProcessorCount = processor.getPhysicalProcessorCount();
      //处理器核心数
      List<CentralProcessor.PhysicalProcessor> physicalProcessors = processor.getPhysicalProcessors();
      //逻辑处理器数
      int logicalProcessorCount = processor.getLogicalProcessorCount();
      //cpu频率
      long[] currentFreq = processor.getCurrentFreq();
      long maxFreq = processor.getMaxFreq();

      //mac地址
      List<NetworkIF> networkIFs = hardware.getNetworkIFs();

      //内存
      GlobalMemory memory = hardware.getMemory();

      //硬盘
      List<HWDiskStore> diskStores = hardware.getDiskStores();

      //显卡
      List<GraphicsCard> graphicsCards = hardware.getGraphicsCards();

      //主板信息
      ComputerSystem computerSystem = hardware.getComputerSystem();
      Baseboard baseboard = computerSystem.getBaseboard();


      System.out.println("制造商: " + baseboard.getManufacturer());
      System.out.println("主板号: " + baseboard.getSerialNumber());

      Map<String,Object>map = new HashMap<>();
map.put("name",name);
map.put("physicalProcessorCount",physicalProcessorCount);
map.put("logicalProcessorCount",logicalProcessorCount);
map.put("currentFreq",currentFreq);
map.put("maxFreq",maxFreq);
map.put("networkIFs",networkIFs);
map.put("memory",memory);
map.put("diskStores",diskStores);
map.put("graphicsCards",graphicsCards);
map.put("baseboardManufacture",baseboard.getManufacturer());
      map.put("baseboardSerialNumber",baseboard.getSerialNumber());
map.put("physicalProcessors",physicalProcessors);
      return map;

   }


}
